#include "dialog.h"
#include<QGridLayout>
#define PI 3.1415926

Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
{
    //对相关变量进行初始化
    qLab1 = new QLabel("请输入你的半径值:",this);
    qLab2 = new QLabel(this);
    qLine = new QLineEdit(this);
    qPbt = new QPushButton("确认", this);

    //对相关控件进行布局
    QGridLayout * pGridLay = new QGridLayout(this);
    pGridLay->addWidget(qLab1, 0, 0);
    pGridLay->addWidget(qLine, 0, 1);
    pGridLay->addWidget(qLab2, 1, 0);
    pGridLay->addWidget(qPbt, 1, 1);

    //槽函数进行控制
    connect(qLine, SIGNAL(textChanged(QString)), this, SLOT(CalTube()));
}

Dialog::~Dialog()
{
}

void Dialog::CalTube() //计算体积
{
    bool Isok;
    QString tmpStr = "";
    double nCal =  qLine->text().toInt(&Isok);
    double dSum = 4.0/3.0*PI*nCal*nCal*nCal;
    qLab2->setText(tmpStr.setNum(dSum));
}
